package com.digitalchina.lxnsy.viewholder;

import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.RealTimeListVO;
import com.digitalchina.lxnsy.toolkit.DateStyle;
import com.digitalchina.lxnsy.toolkit.DateUtil;
import com.digitalchina.lxnsy.toolkit.Utils;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：白彦东
 * 创建时间：2016/12/28 18:10
 * 修改备注：
 * ================================================
 */

public class RealTimePriceDataDetailsHolder extends BaseViewHolder<RealTimeListVO> {

    private TextView tvDataDetailsDate;
    private TextView tvDataDetailsPrice;
    private RelativeLayout layoutRelative;


    public RealTimePriceDataDetailsHolder(ViewGroup parent) {
        super(parent, R.layout.item_real_time_price_data_details);
        tvDataDetailsDate = $(R.id.item_real_data_details_tv_date);
        tvDataDetailsPrice = $(R.id.item_real_data_details_tv_price);
        layoutRelative = $(R.id.item_layout_real_time_price_data_details);
    }

    @Override
    public void setData(RealTimeListVO data) {
        super.setData(data);

        if (getAdapterPosition() % 2 == 0) {// Item颜色间隔不同
            layoutRelative.setBackgroundColor(getContext().getResources().getColor(R.color.app_activity_bar_background));
        } else {
            layoutRelative.setBackgroundColor(getContext().getResources().getColor(R.color.colorWhite));
        }

        tvDataDetailsDate.setText(TextUtils.isEmpty(data.getDate()) ? "" : DateUtil.StringToString(data.getDate(), DateStyle.YYYY_MM_DD_EN));
        tvDataDetailsPrice.setText(String.format("￥%s - ￥%s", TextUtils.isEmpty(data.getLowPrice()) ? "" : Utils.formatPrice(data.getLowPrice()), TextUtils.isEmpty(data.getHighPrice()) ? "" : Utils.formatPrice(data.getHighPrice())));

    }

}
